package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.generator.entity.FireForecastDataEntity;
import io.renren.modules.generator.service.FireForecastDataService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author rose
 * @email 1942951600@qq.com
 * @date 2021-08-06 21:32:44
 */
@RestController
@RequestMapping("generator/fireforecastdata")
@Api(tags = "火情相关接口" , description = "FireForecastDataController | 火情模块")
public class FireForecastDataController {
    @Autowired
    private FireForecastDataService fireForecastDataService;

    /**
     * 列表
     */
    @ApiOperation("条件查询")
    @GetMapping("/list")
    @RequiresPermissions("generator:fireforecastdata:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = fireForecastDataService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("分页列出所有的火情")
    @GetMapping("/info/{fireTime}")
    @RequiresPermissions("generator:fireforecastdata:info")
    public R info(@PathVariable("fireTime") String  id){
		FireForecastDataEntity fireForecastData = fireForecastDataService.getById(id);

        return R.ok().put("fireForecastData", fireForecastData);
    }

    /**
     * 保存
     */
    @ApiOperation("添加数据")
    @PostMapping("/save")
    @RequiresPermissions("generator:fireforecastdata:save")
    public R save(@RequestBody FireForecastDataEntity fireForecastData){
		fireForecastDataService.save(fireForecastData);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改数据")
    @PostMapping("/update")
    @RequiresPermissions("generator:fireforecastdata:update")
    public R update(@RequestBody FireForecastDataEntity fireForecastData){
		fireForecastDataService.updateById(fireForecastData);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除数据")
    @PostMapping("/delete")
    @RequiresPermissions("generator:fireforecastdata:delete")
    public R delete(@RequestBody Date[] fireTimes){
		fireForecastDataService.removeByIds(Arrays.asList(fireTimes));

        return R.ok();
    }

}
